<template>
  <div class="partner" ref="partner">
    <div class="p-text">
      <p class="bold">{{ props.stats?.approvalClose.name }}</p>
      <p>你还记得这位小伙伴吗？</p>
      <p>
        Ta和你一共参与了<span class="keyword">{{
          props.stats?.approvalClose.quantity
        }}</span>次流程
      </p>
      <p>当之无愧的是你的<span class="bold">最佳拍档</span></p>
      <div class="p-t-tip">
        <p>通过邮件时光机</p>
        <p>我们查询到以下小伙伴和你无话不谈</p>
      </div>
    </div>

    <ul class="p-partner-list">
      <li v-for="(item, index) of props.stats?.emailClose" :key="index"
        :class="textStrokeStyle(index as 1 | 2 | 3 | 4 | 0)">
        <span>{{ item.name }}</span>
        <span>{{ item.num }}封</span>
      </li>
    </ul>

    <img class="p-bubble-decorator" src="@/assets/img/partner/bg-bubble.png" />
  </div>
</template>

<script lang="ts" setup>
import { onMounted, ref } from "vue";
import { slideUp, slideDown } from "@/utils/slide";

const props = defineProps<{
  stats: any;
}>();

const emit = defineEmits(["slideUp", "slideDown"]);

onMounted(() => {
  slideUp(partner.value, () => {
    console.log("hello");
    emit("slideUp");
  });
  slideDown(partner.value, () => {
    emit("slideDown");
  });
});

const partner = ref(null);

const textStrokeStyle = (index: 1 | 2 | 3 | 4 | 0) => {
  switch (index) {
    case 0:
      return "blue";
    case 3:
      return "red";
    case 1:
      return "orange";
    case 2:
      return "yellow";
    case 4:
      return "green";
  }
};
</script>

<script lang="ts">
export default {
  name: "PartnerPage",
};
</script>

<style lang="scss" scoped>
.partner {
  @include full-screen-relative;
  font-size: 30px;
  font-family: ChangAnunitype;
  color: #ffffff;
  line-height: 60px;
}

.p-text {
  @include animation-fade-in;
  margin-top: 169px;
  margin-left: 63px;

  .p-t-tip {
    margin-top: 170px;
  }

  .bold {
    font-weight: bold;
    font-size: 48px;
  }
}

.p-bubble-decorator {
  position: absolute;
  right: 125px;
  top: 463px;
  height: 597px;
  width: 287px;
}

.p-partner-list {
  position: absolute;
  top: 738px;
  width: 100vw;
  height: 700px;
}

li {
  height: 190px;
  width: 190px;
  font-size: 48px;
  font-weight: bold;
  text-align: center;
  background-repeat: no-repeat;
  background-size: cover;

  span {
    display: block;

    &:first-child {
      margin-top: 35px;
    }

    &:last-child {
      font-size: 36px;
    }
  }

  &.blue {
    @include animation-up-down-shake(5s);
    position: absolute;
    top: 0;
    left: 290px;
    -webkit-text-stroke: 1px #5493fd;
    text-stroke: 1px #5493fd;
    background-image: url("@/assets/img/partner/bubble-blue.png");
  }

  &.red {
    @include animation-up-down-shake(4s);
    position: absolute;
    top: 150px;
    right: 65px;
    height: 130px;
    width: 130px;
    font-size: 36px;
    -webkit-text-stroke: 1px #fa6b6b;
    text-stroke: 1px #fa6b6b;
    background-image: url("@/assets/img/partner/bubble-red.png");

    span {
      &:first-child {
        margin-top: 15px;
      }

      &:last-child {
        font-size: $font-size-normal;
        line-height: 1.2;
      }
    }
  }

  &.orange {
    @include animation-up-down-shake(3.5s);
    position: absolute;
    top: 350px;
    right: 156px;
    -webkit-text-stroke: 1px #f57935;
    text-stroke: 1px #f57935;
    background-image: url("@/assets/img/partner/bubble-orange.png");
  }

  &.yellow {
    @include animation-up-down-shake(4s);
    position: absolute;
    top: 380px;
    left: 148px;
    -webkit-text-stroke: 1px #d39c05;
    text-stroke: 1px #d39c05;
    background-image: url("@/assets/img/partner/bubble-yellow.png");
  }

  &.green {
    @include animation-up-down-shake(4.5s);
    position: absolute;
    top: 170px;
    left: 96px;
    height: 130px;
    width: 130px;
    font-size: 36px;
    -webkit-text-stroke: 1px #05d49c;
    text-stroke: 1px #05d49c;
    background-image: url("@/assets/img/partner/bubble-green.png");

    span {
      &:first-child {
        margin-top: 15px;
      }

      &:last-child {
        font-size: $font-size-normal;
        line-height: 1.2;
      }
    }
  }
}</style>
